#ifndef AED_IMAGE_H
#define AED_IMAGE_H

#include <QString>
#include <QPixmap>
#include <Windows.h>
#include <gl/GL.h>
#include <QTextStream>
#include <QDomDocument>
//#include "AIO_XMLToken.hpp"



class AED_Image{
    private:
        QString	        m_name;
        QString         m_path;
        int             m_loaded;

        int           m_width;
        int           m_height;
        GLubyte         m_depth;
        GLubyte         *pixel_array;

        GLuint          m_texname;

        int             m_x_div;
        int             m_y_div;

        QImage::Format  format;
        QPixmap         m_pixmap;

    public:
        AED_Image();
        ~AED_Image();

        QString GetName() const;
        QString GetPath() const;
        void SetPath(const QString &path);
        void SetName(const QString &name);
        short GetWidth() const;
        short GetHeight() const;
        GLuint GetTexName() const;

        int GetXDiv() const;
        int GetYDiv() const;

        void SetXDiv(int X){m_x_div=X;}
        void SetYDiv(int Y){m_y_div=Y;}

        int Load(const QString &filename);
        void Reload();
        int Free();

        QPixmap ToPixmap();

        //int Parse(const AIO_XMLToken &token);
        void Save(QTextStream &file);
        void Save(QDomDocument &doc, QDomElement &header, const QString &scenePath);

        bool Load(QDomElement &elem);

};

#pragma pack(push, 1) // All data members will placed right next to each other.
typedef struct {
        unsigned char ID_length;
        unsigned char Color_map_type;
        unsigned char Image_type;
        // Color_map_specification
        unsigned short Color_map_origin;
        unsigned short Color_map_length;
        unsigned char Color_map_entry_size;
        // Image_specification
        unsigned short XOrigin;
        unsigned short YOrigin;
        unsigned short Width;
        unsigned short Height;
        unsigned char Image_pixel_size;
        unsigned char Image_descriptor_byte;

} TGA_file_header;
#pragma pack(pop)


#endif // AED_IMAGE_H
